package com.netposa.datawarehouse.bodysearch.web.enums;

import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public enum DeviceAbilityEnum {
   TRAFFIC(1, "traffic"),
   FACE(2, "face"),
   BODY(4, "body"),
   CAMERA(8, "camera"),
   NONMOTOR(16, "nonmotor"),
   GPS(32, "gps"),
   RFID(64, "rfid"),
   WIFI(128, "wifi"),
   ETC(256, "etc"),
   ELECFENCE(512, "elecFence");

   private static final Logger log = LoggerFactory.getLogger(DeviceAbilityEnum.class);
   private int intValue;
   private String stringValue;

   private DeviceAbilityEnum(int intValue, String stringValue) {
      this.intValue = intValue;
      this.stringValue = stringValue;
   }

   public static DeviceAbilityEnum getEnumType(String type) {
      if (StringUtils.isNotBlank(type)) {
         try {
            return valueOf(type);
         } catch (Exception var2) {
            log.error("类型解析错误：{}", type);
            return null;
         }
      } else {
         return null;
      }
   }

   public static String getAbilityStringValueByIntValue(int value) {
      List result = new ArrayList();
      DeviceAbilityEnum[] var2 = values();
      int var3 = var2.length;

      for(int var4 = 0; var4 < var3; ++var4) {
         DeviceAbilityEnum ability = var2[var4];
         if ((value & ability.getIntValue()) == ability.getIntValue()) {
            result.add(ability.getStringValue());
         }
      }

      return StringUtils.join(result.toArray(), ",");
   }

   public static List getAllAbilityStringValues() {
      List result = new ArrayList();
      DeviceAbilityEnum[] var1 = values();
      int var2 = var1.length;

      for(int var3 = 0; var3 < var2; ++var3) {
         DeviceAbilityEnum ability = var1[var3];
         result.add(ability.getStringValue());
      }

      return result;
   }

   public static int getAbilityIntValueByStringValue(String... values) {
      int result = 0;
      if (values != null && values.length > 0) {
         String[] var2 = values;
         int var3 = values.length;

         for(int var4 = 0; var4 < var3; ++var4) {
            String value = var2[var4];
            if (getAllAbilityStringValues().contains(value)) {
               DeviceAbilityEnum ability = getEnumType(value.toUpperCase());
               if (ability != null) {
                  result |= ability.getIntValue();
               }
            }
         }
      }

      return result;
   }

   public static int getAllAbilityIntValue() {
      int result = 0;
      DeviceAbilityEnum[] var1 = values();
      int var2 = var1.length;

      for(int var3 = 0; var3 < var2; ++var3) {
         DeviceAbilityEnum ability = var1[var3];
         result += ability.getIntValue();
      }

      return result;
   }

   public int getIntValue() {
      return this.intValue;
   }

   public String getStringValue() {
      return this.stringValue;
   }
}
